home *** CD-ROM | disk | FTP | other *** search
- package asp.nfx.MSDBQuery;
-
- import asp.util.EResourceUtil;
- import asp.util.ResourceUtil;
- import com.netobjects.nfc.api.CStringArray;
- import com.netobjects.nfc.api.ComponentApp;
- import com.netobjects.nfc.api.DAssetManager;
- import com.netobjects.nfc.api.DDrawPicture;
- import com.netobjects.nfc.api.DImage;
- import com.netobjects.nfc.api.DLayout;
- import com.netobjects.nfc.api.DMessageBox;
- import com.netobjects.nfc.api.DRect;
- import com.netobjects.nfc.api.DSize;
- import com.netobjects.nfc.api.IDInspector;
-
- public class MSDBQuery extends ComponentApp {
- String dbConnection;
- String name;
- int usePreviousQuery;
- String select;
- String from;
- String where;
- String orderBy;
- private String INCLUDEFILE_SUBDIR = "asp";
- DAssetManager assMan;
- String codebase;
- DDrawPicture component;
- protected static transient ResourceUtil resUtil = null;
- static final int MAXASSET = 50;
- int[] assetControl;
- int assetCount;
- boolean published = false;
- static final String SCRIPTDELIMOPEN = "<SCRIPT RUNAT=SERVER LANGUAGE=JSCRIPT>\n";
- static final String SCRIPTDELIMCLOSE = "</SCRIPT>\n";
- // $FF: synthetic field
- static Class class$asp$nfx$MSDBQuery$MSDBQuery;
-
- public String onInstall(DAssetManager cam, String codebase) {
- this.assMan = cam;
- return "MSDBQuery";
- }
-
- public void onDrop(DLayout layout, DRect r, int fDrop) {
- if (fDrop == 1) {
- this.dbConnection = new String("MSDBConnection1");
- this.name = new String(resUtil.getString("value.name"));
- this.usePreviousQuery = 1;
- this.select = new String(resUtil.getString("value.select"));
- this.from = new String(resUtil.getString("value.from"));
- this.where = new String("");
- this.orderBy = new String("");
- this.assetControl = new int[50];
- this.component = new DDrawPicture();
- this.codebase = this.component.getCodeBase();
- this.component.setImageFile(this.codebase + resUtil.getString("image.filename"));
- this.component.SetStyle(1, 1);
- this.component.setStretch(1);
- this.component.SetPositionRect(r.getLeft(), r.getTop(), r.getRight(), r.getBottom());
- this.resizeComponent(this.component);
- layout.AddObject(this.component);
- }
- }
-
- public void onInspect(CStringArray Names, CStringArray Types) {
- Names.Set(resUtil.getString("property.name"));
- Types.Set("String");
- Names.Set(resUtil.getString("property.useprev"));
- Types.Set("Set(" + resUtil.getString("option.useprev") + ")");
- Names.Set(resUtil.getString("property.select"));
- Types.Set("String");
- Names.Set(resUtil.getString("property.from"));
- Types.Set("String");
- Names.Set(resUtil.getString("property.where"));
- Types.Set("String");
- Names.Set(resUtil.getString("property.orderby"));
- Types.Set("String");
- }
-
- public String PropertyListener(String Event, String Value, int Get, int propIndex, IDInspector insp) {
- if (Get == 1) {
- if (Event.compareTo(resUtil.getString("property.name")) == 0) {
- return this.name;
- }
-
- if (Event.compareTo(resUtil.getString("property.useprev")) == 0) {
- return Integer.toString(this.usePreviousQuery);
- }
-
- if (Event.compareTo(resUtil.getString("property.select")) == 0) {
- return this.select;
- }
-
- if (Event.compareTo(resUtil.getString("property.from")) == 0) {
- return this.from;
- }
-
- if (Event.compareTo(resUtil.getString("property.where")) == 0) {
- return this.where;
- }
-
- if (Event.compareTo(resUtil.getString("property.orderby")) == 0) {
- return this.orderBy;
- }
- } else {
- if (Event.compareTo(resUtil.getString("property.name")) == 0 && this.isValidName(Value)) {
- this.name = Value;
- }
-
- if (Event.compareTo(resUtil.getString("property.useprev")) == 0) {
- this.usePreviousQuery = Integer.parseInt(Value, 10);
- }
-
- if (Event.compareTo(resUtil.getString("property.select")) == 0 && this.isValidName(Value)) {
- this.select = Value;
- }
-
- if (Event.compareTo(resUtil.getString("property.from")) == 0 && this.isValidName(Value)) {
- this.from = Value;
- }
-
- if (Event.compareTo(resUtil.getString("property.where")) == 0) {
- this.where = Value;
- }
-
- if (Event.compareTo(resUtil.getString("property.orderby")) == 0) {
- this.orderBy = Value;
- }
- }
-
- return "";
- }
-
- public void onCopy() {
- this.codebase = new String(this.codebase);
- int[] assetControlOld = this.assetControl;
-
- for(int i = 0; i < this.assetCount; ++i) {
- this.assetControl[i] = assetControlOld[i];
- if (this.assetControl[i] != 0) {
- this.assMan.CopyAsset(this.assetControl[i]);
- }
- }
-
- }
-
- public void onPublish(DAssetManager cam, int context) {
- this.removeAssets();
- this.published = true;
- int javaScriptAsset = this.assMan.AddAsset(this.codebase + "MSDBQuery.inc", "JavaScript", "assets\\lib");
- this.assetControl[this.assetCount] = javaScriptAsset;
- this.assMan.SetPublishAssetMode(this.assetControl[this.assetCount++], 453);
- DLayout cidLayout = this.component.getLayout();
- String NestedDir = "";
- String homePath = cidLayout.GetHomePath();
- if (homePath.compareTo("..\\") == 0) {
- NestedDir = ".";
- }
-
- String IncludeFile = "<!--#INCLUDE FILE=\"" + NestedDir + "./assets/lib/MSDBQuery.inc\"-->\n";
- String HTMLHead = "\n";
- HTMLHead = HTMLHead + "<SCRIPT RUNAT=SERVER LANGUAGE=JSCRIPT>\n\n";
- HTMLHead = HTMLHead + "//" + resUtil.getString("text.comment") + "\n";
- HTMLHead = HTMLHead + this.name + " = new MSDBQuery(\n";
- HTMLHead = HTMLHead + " \"" + this.name + "\",\n";
- HTMLHead = HTMLHead + " \"" + this.dbConnection + "\",\n";
- HTMLHead = HTMLHead + " \"" + this.usePreviousQueryToString(this.usePreviousQuery) + "\",\n";
- HTMLHead = HTMLHead + " \"" + this.select + "\",\n";
- HTMLHead = HTMLHead + " \"" + this.from + "\",\n";
- HTMLHead = HTMLHead + " \"" + this.where + "\",\n";
- HTMLHead = HTMLHead + " \"" + this.orderBy + "\"\n";
- HTMLHead = HTMLHead + " );\n";
- HTMLHead = HTMLHead + "</SCRIPT>\n\n";
- cidLayout.setHTMLBefore(IncludeFile + HTMLHead);
- String theHTML = "\n<!--\n";
- this.component.setHTMLBefore(theHTML);
- this.component.setHTMLAfter("-->");
- }
-
- protected void finalize() {
- this.removeAssets();
- }
-
- public void onUnInstall(DAssetManager cam) {
- }
-
- private String usePreviousQueryToString(int value) {
- switch (value) {
- case 0:
- return "true";
- case 1:
- return "false";
- default:
- return "false";
- }
- }
-
- private void removeAssets() {
- if (this.published) {
- for(int i = 0; i < this.assetCount; ++i) {
- this.assMan.RemoveAsset(this.assetControl[i]);
- }
- }
-
- this.assetCount = 0;
- }
-
- public boolean isValidName(String testString) {
- boolean result = true;
- if (testString.compareTo("") == 0) {
- DMessageBox msg = new DMessageBox();
- msg.Warning(resUtil.getString("error.validname"));
- result = false;
- }
-
- return result;
- }
-
- private void resizeComponent(DDrawPicture aPict) {
- DImage imageSizer = new DImage();
- imageSizer.setImageFile(aPict.getImageFile());
- DSize imageSize = imageSizer.getSize();
- aPict.SetSize(imageSize.getWidth(), imageSize.getHeight());
- }
-
- public static ResourceUtil initResourceUtil(Class compClass) {
- ResourceUtil _ru = null;
-
- try {
- _ru = new ResourceUtil("asp.nfx.res", compClass);
- } catch (EResourceUtil e) {
- System.err.println(((Throwable)e).getMessage());
- }
-
- return _ru;
- }
-
- public String propertyManager(String Event, String Value, int Get) {
- if (Get == 1) {
- if (Event.compareTo(resUtil.getString("property.name")) == 0) {
- return this.name;
- }
-
- if (Event.compareTo(resUtil.getString("property.useprev")) == 0) {
- return Integer.toString(this.usePreviousQuery);
- }
-
- if (Event.compareTo(resUtil.getString("property.select")) == 0) {
- return this.select;
- }
-
- if (Event.compareTo(resUtil.getString("property.from")) == 0) {
- return this.from;
- }
-
- if (Event.compareTo(resUtil.getString("property.where")) == 0) {
- return this.where;
- }
-
- if (Event.compareTo(resUtil.getString("property.orderby")) == 0) {
- return this.orderBy;
- }
- } else {
- if (Event.compareTo(resUtil.getString("property.name")) == 0 && this.isValidName(Value)) {
- this.name = Value;
- }
-
- if (Event.compareTo(resUtil.getString("property.useprev")) == 0) {
- this.usePreviousQuery = Integer.parseInt(Value, 10);
- }
-
- if (Event.compareTo(resUtil.getString("property.select")) == 0 && this.isValidName(Value)) {
- this.select = Value;
- }
-
- if (Event.compareTo(resUtil.getString("property.from")) == 0 && this.isValidName(Value)) {
- this.from = Value;
- }
-
- if (Event.compareTo(resUtil.getString("property.where")) == 0) {
- this.where = Value;
- }
-
- if (Event.compareTo(resUtil.getString("property.orderby")) == 0) {
- this.orderBy = Value;
- }
- }
-
- return "";
- }
-
- // $FF: synthetic method
- static Class class$(String class$) {
- try {
- return Class.forName(class$);
- } catch (ClassNotFoundException forName) {
- throw new NoClassDefFoundError(((Throwable)forName).getMessage());
- }
- }
-
- static {
- resUtil = initResourceUtil(class$asp$nfx$MSDBQuery$MSDBQuery != null ? class$asp$nfx$MSDBQuery$MSDBQuery : (class$asp$nfx$MSDBQuery$MSDBQuery = class$("asp.nfx.MSDBQuery.MSDBQuery")));
- }
- }
-